package com.ccz.demo.design.builder.computer;


public class ComputerBuildSelf {
    private final String motherBoard;     // 主板
    private final String cpu;           // cpu
    private final String disk;            // 硬盘
    private final String powerSupplier; // 电源
    private final String graphicsCard;   // 显卡
    private final String mouse; // 鼠标
    private final String computerCase; //机箱
    private final String mousePad;   //鼠标垫
    private final String other;  //其它配件

    private ComputerBuildSelf(Builder builder) {
        this.motherBoard = builder.motherBoard;
        this.cpu = builder.cpu;
        this.disk = builder.disk;
        this.powerSupplier = builder.powerSupplier;
        this.graphicsCard = builder.graphicsCard;
        this.mouse = builder.mouse;
        this.computerCase = builder.computerCase;
        this.mousePad = builder.mousePad;
        this.other = builder.other;
    }

    // 只暴漏getter方法到外部
    public String getMotherBoard() {
        return motherBoard;
    }

    public String getCpu() {
        return cpu;
    }

    public String getDisk() {
        return disk;
    }

    public String getPowerSupplier() {
        return powerSupplier;
    }

    public String getGraphicsCard() {
        return graphicsCard;
    }

    public String getMouse() {
        return mouse;
    }

    public String getComputerCase() {
        return computerCase;
    }

    public String getMousePad() {
        return mousePad;
    }

    public String getOther() {
        return other;
    }


    public static Builder basic() {
        Builder builder = new Builder();
        return builder.cpu("i5-7200u").disk("250固态硬盘").motherBoard("微星迫击炮");
    }

    public static class Builder {
        private String motherBoard;     // 主板
        private String cpu;           // cpu
        private String disk;            // 硬盘
        private String powerSupplier; // 电源
        private String graphicsCard;   // 显卡
        private String mouse; // 鼠标
        private String computerCase; //机箱
        private String mousePad;   //鼠标垫
        private String other;  //其它配件

        public Builder motherBoard(String motherBoard) {
            this.motherBoard = motherBoard;
            return this;
        }

        public Builder cpu(String cpu) {
            this.cpu = cpu;
            return this;
        }

        public Builder disk(String disk) {
            this.disk = disk;
            return this;
        }


        public Builder powerSupplier(String powerSupplier) {
            this.powerSupplier = powerSupplier;
            return this;
        }


        public Builder mouse(String mouse) {
            this.mouse = mouse;
            return this;
        }

        public Builder computerCase(String computerCase) {
            this.computerCase = computerCase;
            return this;
        }

        public Builder mousePad(String mousePad) {
            this.mousePad = mousePad;
            return this;
        }

        public Builder other(String other) {
            this.other = other;
            return this;
        }

        public ComputerBuildSelf build() {
            return new ComputerBuildSelf(this);
        }

    }
}
